package com.wlj.security.browser.session;

import org.springframework.security.web.session.SessionInformationExpiredEvent;
import org.springframework.security.web.session.SessionInformationExpiredStrategy;

import javax.servlet.ServletException;
import java.io.IOException;

/**
 *maximumSessions(1)设置同一用户多端登陆只能有一个session，后面登陆的可以踢掉前面登陆的会话
 *此类处理踢除事件发生时的处理逻辑，可以记录一下
 */
public class WljExpiredSessionStrategy extends AbstractSessionStrategy  implements SessionInformationExpiredStrategy {
    /**
     * @param invalidSessionUrl
     */
    public WljExpiredSessionStrategy(String invalidSessionUrl) {
        super(invalidSessionUrl);
    }

    @Override
    public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException {
        onSessionInvalid(event.getRequest(), event.getResponse());
    }

    /* (non-Javadoc)
     * @see com.imooc.security.browser.session.AbstractSessionStrategy#isConcurrency()
     */
    @Override
    protected boolean isConcurrency() {
        return true;
    }
}
